{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'pandas'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[1], line 2\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpandas\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mpd\u001b[39;00m\n\u001b[0;32m      3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmatplotlib\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpyplot\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mplt\u001b[39;00m\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'pandas'"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_excel(\"数据列表（20240317~20240505）.xlsx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'df' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[2], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m df \u001b[38;5;241m=\u001b[39m df\u001b[38;5;241m.\u001b[39miloc[::\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\u001b[38;5;241m.\u001b[39mreset_index(drop\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
      "\u001b[1;31mNameError\u001b[0m: name 'df' is not defined"
     ]
    }
   ],
   "source": [
    "df = df.iloc[::-1].reset_index(drop=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'df' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[3], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m df \u001b[38;5;241m=\u001b[39m df\u001b[38;5;241m.\u001b[39mloc[:,[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m土壤温度\u001b[39m\u001b[38;5;124m'\u001b[39m,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m空气温度\u001b[39m\u001b[38;5;124m'\u001b[39m,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m空气湿度\u001b[39m\u001b[38;5;124m'\u001b[39m]]\n",
      "\u001b[1;31mNameError\u001b[0m: name 'df' is not defined"
     ]
    }
   ],
   "source": [
    "df = df.loc[:,['土壤温度','空气温度','空气湿度']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'df' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[4], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;28mlen\u001b[39m(df)):\n\u001b[0;32m      2\u001b[0m     df\u001b[38;5;241m.\u001b[39miloc[i,\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mfloat\u001b[39m(df\u001b[38;5;241m.\u001b[39miloc[i,\u001b[38;5;241m0\u001b[39m][:\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m])\n\u001b[0;32m      3\u001b[0m     df\u001b[38;5;241m.\u001b[39miloc[i,\u001b[38;5;241m1\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mfloat\u001b[39m(df\u001b[38;5;241m.\u001b[39miloc[i,\u001b[38;5;241m1\u001b[39m][:\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m])\n",
      "\u001b[1;31mNameError\u001b[0m: name 'df' is not defined"
     ]
    }
   ],
   "source": [
    "for i in range(len(df)):\n",
    "    df.iloc[i,0] = float(df.iloc[i,0][:-1])\n",
    "    df.iloc[i,1] = float(df.iloc[i,1][:-1])\n",
    "    df.iloc[i,2] = float(df.iloc[i,2][:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>土壤温度</th>\n",
       "      <th>空气温度</th>\n",
       "      <th>空气湿度</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.7</td>\n",
       "      <td>72.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.7</td>\n",
       "      <td>72.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5762</th>\n",
       "      <td>22.97</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5763</th>\n",
       "      <td>22.97</td>\n",
       "      <td>22.2</td>\n",
       "      <td>99.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5764</th>\n",
       "      <td>22.97</td>\n",
       "      <td>22.3</td>\n",
       "      <td>99.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5765</th>\n",
       "      <td>22.97</td>\n",
       "      <td>22.4</td>\n",
       "      <td>99.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5766</th>\n",
       "      <td>22.97</td>\n",
       "      <td>22.4</td>\n",
       "      <td>99.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5767 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       土壤温度  空气温度  空气湿度\n",
       "0      21.0  21.7  72.6\n",
       "1      21.0  21.7  72.5\n",
       "2      21.0  21.8  72.6\n",
       "3      21.0  21.8  72.5\n",
       "4     21.03  21.8  72.3\n",
       "...     ...   ...   ...\n",
       "5762  22.97  22.1  99.8\n",
       "5763  22.97  22.2  99.8\n",
       "5764  22.97  22.3  99.7\n",
       "5765  22.97  22.4  99.5\n",
       "5766  22.97  22.4  99.5\n",
       "\n",
       "[5767 rows x 3 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = df\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# from sklearn.preprocessing import MinMaxScaler\n",
    "# scaler1 = MinMaxScaler(feature_range=(0, 1))\n",
    "# scaler2 = MinMaxScaler(feature_range=(0, 1))\n",
    "# feature = scaler1.fit_transform(data.iloc[:,1:])\n",
    "# target = scaler2.fit_transform(data.iloc[:,0:1])\n",
    "# data = pd.concat([pd.DataFrame(target),pd.DataFrame(feature)],axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "#这里生成look_back的序列，在这里生成数据集\n",
    "from pandas import DataFrame\n",
    "from pandas import concat\n",
    "def series_to_supervised(data, n_in=1, n_out=1, dropnan=True):  #n_in:look_back\n",
    "    n_vars = 1 if type(data) is list else data.shape[1]\n",
    "    df = DataFrame(data)\n",
    "    cols, names = list(), list()\n",
    "    for i in range(n_in, 0, -1):\n",
    "        cols.append(df.shift(i))\n",
    "        names += [('var%d(t-%d)' % (j + 1, i)) for j in range(n_vars)]\n",
    "    for i in range(0, n_out):\n",
    "        cols.append(df.shift(-i))\n",
    "        if i == 0:\n",
    "            names += [('var%d(t)' % (j + 1)) for j in range(n_vars)]\n",
    "        else:\n",
    "            names += [('var%d(t+%d)' % (j + 1, i)) for j in range(n_vars)]\n",
    "    agg = concat(cols, axis=1)\n",
    "    agg.columns = names\n",
    "    if dropnan:\n",
    "        agg.dropna(inplace=True)\n",
    "    return agg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "forward = 6\n",
    "#多步只需要修改这个地方out\n",
    "out = 1\n",
    "data = series_to_supervised(data, forward, out)\n",
    "data = data.reset_index(drop=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var1(t-6)</th>\n",
       "      <th>var2(t-6)</th>\n",
       "      <th>var3(t-6)</th>\n",
       "      <th>var1(t-5)</th>\n",
       "      <th>var2(t-5)</th>\n",
       "      <th>var3(t-5)</th>\n",
       "      <th>var1(t-4)</th>\n",
       "      <th>var2(t-4)</th>\n",
       "      <th>var3(t-4)</th>\n",
       "      <th>var1(t-3)</th>\n",
       "      <th>...</th>\n",
       "      <th>var3(t-3)</th>\n",
       "      <th>var1(t-2)</th>\n",
       "      <th>var2(t-2)</th>\n",
       "      <th>var3(t-2)</th>\n",
       "      <th>var1(t-1)</th>\n",
       "      <th>var2(t-1)</th>\n",
       "      <th>var3(t-1)</th>\n",
       "      <th>var1(t)</th>\n",
       "      <th>var2(t)</th>\n",
       "      <th>var3(t)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.7</td>\n",
       "      <td>72.6</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.7</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.6</td>\n",
       "      <td>21.0</td>\n",
       "      <td>...</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.7</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.6</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.03</td>\n",
       "      <td>...</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.08</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.6</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.03</td>\n",
       "      <td>...</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.08</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.19</td>\n",
       "      <td>21.11</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.03</td>\n",
       "      <td>...</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.08</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.19</td>\n",
       "      <td>21.11</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.06</td>\n",
       "      <td>21.9</td>\n",
       "      <td>72.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.08</td>\n",
       "      <td>...</td>\n",
       "      <td>72.19</td>\n",
       "      <td>21.11</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.06</td>\n",
       "      <td>21.9</td>\n",
       "      <td>72.0</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.9</td>\n",
       "      <td>72.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5756</th>\n",
       "      <td>23.3</td>\n",
       "      <td>22.5</td>\n",
       "      <td>98.5</td>\n",
       "      <td>23.28</td>\n",
       "      <td>22.4</td>\n",
       "      <td>98.4</td>\n",
       "      <td>23.17</td>\n",
       "      <td>22.4</td>\n",
       "      <td>98.7</td>\n",
       "      <td>23.12</td>\n",
       "      <td>...</td>\n",
       "      <td>98.9</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.2</td>\n",
       "      <td>98.8</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.1</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5757</th>\n",
       "      <td>23.28</td>\n",
       "      <td>22.4</td>\n",
       "      <td>98.4</td>\n",
       "      <td>23.17</td>\n",
       "      <td>22.4</td>\n",
       "      <td>98.7</td>\n",
       "      <td>23.12</td>\n",
       "      <td>22.3</td>\n",
       "      <td>98.9</td>\n",
       "      <td>23.07</td>\n",
       "      <td>...</td>\n",
       "      <td>98.8</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.1</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.2</td>\n",
       "      <td>99.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5758</th>\n",
       "      <td>23.17</td>\n",
       "      <td>22.4</td>\n",
       "      <td>98.7</td>\n",
       "      <td>23.12</td>\n",
       "      <td>22.3</td>\n",
       "      <td>98.9</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.2</td>\n",
       "      <td>98.8</td>\n",
       "      <td>23.07</td>\n",
       "      <td>...</td>\n",
       "      <td>99.1</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.2</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.3</td>\n",
       "      <td>99.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5759</th>\n",
       "      <td>23.12</td>\n",
       "      <td>22.3</td>\n",
       "      <td>98.9</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.2</td>\n",
       "      <td>98.8</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.1</td>\n",
       "      <td>22.97</td>\n",
       "      <td>...</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.2</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.3</td>\n",
       "      <td>99.7</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.4</td>\n",
       "      <td>99.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5760</th>\n",
       "      <td>23.07</td>\n",
       "      <td>22.2</td>\n",
       "      <td>98.8</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.1</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>...</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.3</td>\n",
       "      <td>99.7</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.4</td>\n",
       "      <td>99.5</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.4</td>\n",
       "      <td>99.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5761 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     var1(t-6) var2(t-6) var3(t-6) var1(t-5) var2(t-5) var3(t-5) var1(t-4)  \\\n",
       "0         21.0      21.7      72.6      21.0      21.7      72.5      21.0   \n",
       "1         21.0      21.7      72.5      21.0      21.8      72.6      21.0   \n",
       "2         21.0      21.8      72.6      21.0      21.8      72.5     21.03   \n",
       "3         21.0      21.8      72.5     21.03      21.8      72.3     21.03   \n",
       "4        21.03      21.8      72.3     21.03      21.8      72.1     21.03   \n",
       "...        ...       ...       ...       ...       ...       ...       ...   \n",
       "5756      23.3      22.5      98.5     23.28      22.4      98.4     23.17   \n",
       "5757     23.28      22.4      98.4     23.17      22.4      98.7     23.12   \n",
       "5758     23.17      22.4      98.7     23.12      22.3      98.9     23.07   \n",
       "5759     23.12      22.3      98.9     23.07      22.2      98.8     23.07   \n",
       "5760     23.07      22.2      98.8     23.07      22.1      99.1     22.97   \n",
       "\n",
       "     var2(t-4) var3(t-4) var1(t-3)  ... var3(t-3) var1(t-2) var2(t-2)  \\\n",
       "0         21.8      72.6      21.0  ...      72.5     21.03      21.8   \n",
       "1         21.8      72.5     21.03  ...      72.3     21.03      21.8   \n",
       "2         21.8      72.3     21.03  ...      72.1     21.03      21.8   \n",
       "3         21.8      72.1     21.03  ...      72.3     21.08      21.8   \n",
       "4         21.8      72.3     21.08  ...     72.19     21.11      21.8   \n",
       "...        ...       ...       ...  ...       ...       ...       ...   \n",
       "5756      22.4      98.7     23.12  ...      98.9     23.07      22.2   \n",
       "5757      22.3      98.9     23.07  ...      98.8     23.07      22.1   \n",
       "5758      22.2      98.8     23.07  ...      99.1     22.97      22.1   \n",
       "5759      22.1      99.1     22.97  ...      99.8     22.97      22.2   \n",
       "5760      22.1      99.8     22.97  ...      99.8     22.97      22.3   \n",
       "\n",
       "     var3(t-2) var1(t-1) var2(t-1) var3(t-1) var1(t) var2(t) var3(t)  \n",
       "0         72.3     21.03      21.8      72.1   21.03    21.8    72.3  \n",
       "1         72.1     21.03      21.8      72.3   21.08    21.8   72.19  \n",
       "2         72.3     21.08      21.8     72.19   21.11    21.8    72.1  \n",
       "3        72.19     21.11      21.8      72.1   21.06    21.9    72.0  \n",
       "4         72.1     21.06      21.9      72.0   21.03    21.9    72.0  \n",
       "...        ...       ...       ...       ...     ...     ...     ...  \n",
       "5756      98.8     23.07      22.1      99.1   22.97    22.1    99.8  \n",
       "5757      99.1     22.97      22.1      99.8   22.97    22.2    99.8  \n",
       "5758      99.8     22.97      22.2      99.8   22.97    22.3    99.7  \n",
       "5759      99.8     22.97      22.3      99.7   22.97    22.4    99.5  \n",
       "5760      99.7     22.97      22.4      99.5   22.97    22.4    99.5  \n",
       "\n",
       "[5761 rows x 21 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "data.drop(data.columns[[-1,-2]],axis=1, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var1(t-6)</th>\n",
       "      <th>var2(t-6)</th>\n",
       "      <th>var3(t-6)</th>\n",
       "      <th>var1(t-5)</th>\n",
       "      <th>var2(t-5)</th>\n",
       "      <th>var3(t-5)</th>\n",
       "      <th>var1(t-4)</th>\n",
       "      <th>var2(t-4)</th>\n",
       "      <th>var3(t-4)</th>\n",
       "      <th>var1(t-3)</th>\n",
       "      <th>var2(t-3)</th>\n",
       "      <th>var3(t-3)</th>\n",
       "      <th>var1(t-2)</th>\n",
       "      <th>var2(t-2)</th>\n",
       "      <th>var3(t-2)</th>\n",
       "      <th>var1(t-1)</th>\n",
       "      <th>var2(t-1)</th>\n",
       "      <th>var3(t-1)</th>\n",
       "      <th>var1(t)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.7</td>\n",
       "      <td>72.6</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.7</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.6</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.7</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.6</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.6</td>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.08</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.19</td>\n",
       "      <td>21.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>21.0</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.5</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.08</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.19</td>\n",
       "      <td>21.11</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.03</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.3</td>\n",
       "      <td>21.08</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.19</td>\n",
       "      <td>21.11</td>\n",
       "      <td>21.8</td>\n",
       "      <td>72.1</td>\n",
       "      <td>21.06</td>\n",
       "      <td>21.9</td>\n",
       "      <td>72.0</td>\n",
       "      <td>21.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5756</th>\n",
       "      <td>23.3</td>\n",
       "      <td>22.5</td>\n",
       "      <td>98.5</td>\n",
       "      <td>23.28</td>\n",
       "      <td>22.4</td>\n",
       "      <td>98.4</td>\n",
       "      <td>23.17</td>\n",
       "      <td>22.4</td>\n",
       "      <td>98.7</td>\n",
       "      <td>23.12</td>\n",
       "      <td>22.3</td>\n",
       "      <td>98.9</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.2</td>\n",
       "      <td>98.8</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.1</td>\n",
       "      <td>22.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5757</th>\n",
       "      <td>23.28</td>\n",
       "      <td>22.4</td>\n",
       "      <td>98.4</td>\n",
       "      <td>23.17</td>\n",
       "      <td>22.4</td>\n",
       "      <td>98.7</td>\n",
       "      <td>23.12</td>\n",
       "      <td>22.3</td>\n",
       "      <td>98.9</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.2</td>\n",
       "      <td>98.8</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.1</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5758</th>\n",
       "      <td>23.17</td>\n",
       "      <td>22.4</td>\n",
       "      <td>98.7</td>\n",
       "      <td>23.12</td>\n",
       "      <td>22.3</td>\n",
       "      <td>98.9</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.2</td>\n",
       "      <td>98.8</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.1</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.2</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5759</th>\n",
       "      <td>23.12</td>\n",
       "      <td>22.3</td>\n",
       "      <td>98.9</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.2</td>\n",
       "      <td>98.8</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.1</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.2</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.3</td>\n",
       "      <td>99.7</td>\n",
       "      <td>22.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5760</th>\n",
       "      <td>23.07</td>\n",
       "      <td>22.2</td>\n",
       "      <td>98.8</td>\n",
       "      <td>23.07</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.1</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.1</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.2</td>\n",
       "      <td>99.8</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.3</td>\n",
       "      <td>99.7</td>\n",
       "      <td>22.97</td>\n",
       "      <td>22.4</td>\n",
       "      <td>99.5</td>\n",
       "      <td>22.97</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5761 rows × 19 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     var1(t-6) var2(t-6) var3(t-6) var1(t-5) var2(t-5) var3(t-5) var1(t-4)  \\\n",
       "0         21.0      21.7      72.6      21.0      21.7      72.5      21.0   \n",
       "1         21.0      21.7      72.5      21.0      21.8      72.6      21.0   \n",
       "2         21.0      21.8      72.6      21.0      21.8      72.5     21.03   \n",
       "3         21.0      21.8      72.5     21.03      21.8      72.3     21.03   \n",
       "4        21.03      21.8      72.3     21.03      21.8      72.1     21.03   \n",
       "...        ...       ...       ...       ...       ...       ...       ...   \n",
       "5756      23.3      22.5      98.5     23.28      22.4      98.4     23.17   \n",
       "5757     23.28      22.4      98.4     23.17      22.4      98.7     23.12   \n",
       "5758     23.17      22.4      98.7     23.12      22.3      98.9     23.07   \n",
       "5759     23.12      22.3      98.9     23.07      22.2      98.8     23.07   \n",
       "5760     23.07      22.2      98.8     23.07      22.1      99.1     22.97   \n",
       "\n",
       "     var2(t-4) var3(t-4) var1(t-3) var2(t-3) var3(t-3) var1(t-2) var2(t-2)  \\\n",
       "0         21.8      72.6      21.0      21.8      72.5     21.03      21.8   \n",
       "1         21.8      72.5     21.03      21.8      72.3     21.03      21.8   \n",
       "2         21.8      72.3     21.03      21.8      72.1     21.03      21.8   \n",
       "3         21.8      72.1     21.03      21.8      72.3     21.08      21.8   \n",
       "4         21.8      72.3     21.08      21.8     72.19     21.11      21.8   \n",
       "...        ...       ...       ...       ...       ...       ...       ...   \n",
       "5756      22.4      98.7     23.12      22.3      98.9     23.07      22.2   \n",
       "5757      22.3      98.9     23.07      22.2      98.8     23.07      22.1   \n",
       "5758      22.2      98.8     23.07      22.1      99.1     22.97      22.1   \n",
       "5759      22.1      99.1     22.97      22.1      99.8     22.97      22.2   \n",
       "5760      22.1      99.8     22.97      22.2      99.8     22.97      22.3   \n",
       "\n",
       "     var3(t-2) var1(t-1) var2(t-1) var3(t-1) var1(t)  \n",
       "0         72.3     21.03      21.8      72.1   21.03  \n",
       "1         72.1     21.03      21.8      72.3   21.08  \n",
       "2         72.3     21.08      21.8     72.19   21.11  \n",
       "3        72.19     21.11      21.8      72.1   21.06  \n",
       "4         72.1     21.06      21.9      72.0   21.03  \n",
       "...        ...       ...       ...       ...     ...  \n",
       "5756      98.8     23.07      22.1      99.1   22.97  \n",
       "5757      99.1     22.97      22.1      99.8   22.97  \n",
       "5758      99.8     22.97      22.2      99.8   22.97  \n",
       "5759      99.8     22.97      22.3      99.7   22.97  \n",
       "5760      99.7     22.97      22.4      99.5   22.97  \n",
       "\n",
       "[5761 rows x 19 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_230771/4112693823.py:1: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
      "  data.iloc[0][0]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "21.0"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[0][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [],
   "source": [
    "def generate_template(data, columns, forward):\n",
    "    r1_text = []\n",
    "    for j in range(len(data)):\n",
    "        template_data = []\n",
    "        for i in range(1, forward+1):\n",
    "            s = (i-1)*len(columns)\n",
    "            for column in columns:\n",
    "                template_data.append(f\"{column}{(forward-i)*20}分钟前的数值为{data.iloc[j][s]}\")\n",
    "                s = s + 1\n",
    "        template_data.append(f\"{columns[0]}未来20分钟的数值为{data.iloc[j][-1]}\")\n",
    "        # 返回拼接后的文本\n",
    "        r1_text.append( \"，\".join(template_data))\n",
    "    return r1_text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_230771/1182962057.py:8: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
      "  template_data.append(f\"{column}{(forward-i)*20}分钟前的数值为{data.iloc[j][s]}\")\n",
      "/tmp/ipykernel_230771/1182962057.py:10: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
      "  template_data.append(f\"{columns[0]}未来20分钟的数值为{data.iloc[j][-1]}\")\n"
     ]
    }
   ],
   "source": [
    "text = generate_template(data, df.columns, forward)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'土壤温度100分钟前的数值为21.0，空气温度100分钟前的数值为21.7，空气湿度100分钟前的数值为72.6，土壤温度80分钟前的数值为21.0，空气温度80分钟前的数值为21.7，空气湿度80分钟前的数值为72.5，土壤温度60分钟前的数值为21.0，空气温度60分钟前的数值为21.8，空气湿度60分钟前的数值为72.6，土壤温度40分钟前的数值为21.0，空气温度40分钟前的数值为21.8，空气湿度40分钟前的数值为72.5，土壤温度20分钟前的数值为21.03，空气温度20分钟前的数值为21.8，空气湿度20分钟前的数值为72.3，土壤温度0分钟前的数值为21.03，空气温度0分钟前的数值为21.8，空气湿度0分钟前的数值为72.1，土壤温度未来20分钟的数值为21.03'"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'土壤温度100分钟前的数值为21.0，空气温度100分钟前的数值为21.7，空气湿度100分钟前的数值为72.6，土壤温度80分钟前的数值为21.0，空气温度80分钟前的数值为21.7，空气湿度80分钟前的数值为72.5，土壤温度60分钟前的数值为21.0，空气温度60分钟前的数值为21.8，空气湿度60分钟前的数值为72.6，土壤温度40分钟前的数值为21.0，空气温度40分钟前的数值为21.8，空气湿度40分钟前的数值为72.5，土壤温度20分钟前的数值为21.03，空气温度20分钟前的数值为21.8，空气湿度20分钟前的数值为72.3，土壤温度0分钟前的数值为21.03，空气温度0分钟前的数值为21.8，空气湿度0分钟前的数值为72.1'"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0].rsplit(\"，\", 1)[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_openai import ChatOpenAI, OpenAIEmbeddings\n",
    "from langchain_core.prompts import PromptTemplate, ChatPromptTemplate\n",
    "from langchain_core.output_parsers import StrOutputParser\n",
    "parser = StrOutputParser()\n",
    "llm = ChatOpenAI(model=\"deepseek-reasoner\", temperature=0,api_key='sk-zk296e1a1b3cdb88c1be349e0da6283e0036757dc77b0f0d',base_url='https://api.zhizengzeng.com/v1')\n",
    "chain = prompt | llm | parser"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "#改进prompt模板，例如换数据展示的模板？可以给更多详细的角色定位，或者给予任务提示，比如诱导它每次都分析数学公式进行拟合？都可以，可以多尝试多种prompt\n",
    "prompt = ChatPromptTemplate.from_template(\"\"\"\n",
    "预测当前的土壤温度。\n",
    "请参考以下历史数据，包含历史数据和当前的土壤温度数据:{history}\n",
    "你需要预测的数据为:{today}\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['土壤温度120分钟前的数值为24.59，空气温度120分钟前的数值为25.3，空气湿度120分钟前的数值为78.9，土壤温度100分钟前的数值为24.49，空气温度100分钟前的数值为25.2，空气湿度100分钟前的数值为78.8，土壤温度80分钟前的数值为24.44，空气温度80分钟前的数值为25.1，空气湿度80分钟前的数值为79.3，土壤温度60分钟前的数值为24.39，空气温度60分钟前的数值为25.0，空气湿度60分钟前的数值为80.3，土壤温度40分钟前的数值为24.29，空气温度40分钟前的数值为24.8，空气湿度40分钟前的数值为80.1，土壤温度20分钟前的数值为24.19，空气温度20分钟前的数值为24.6，空气湿度20分钟前的数值为80.69，土壤温度当前的数值为24.14',\n",
       " '土壤温度120分钟前的数值为24.49，空气温度120分钟前的数值为25.2，空气湿度120分钟前的数值为78.8，土壤温度100分钟前的数值为24.44，空气温度100分钟前的数值为25.1，空气湿度100分钟前的数值为79.3，土壤温度80分钟前的数值为24.39，空气温度80分钟前的数值为25.0，空气湿度80分钟前的数值为80.3，土壤温度60分钟前的数值为24.29，空气温度60分钟前的数值为24.8，空气湿度60分钟前的数值为80.1，土壤温度40分钟前的数值为24.19，空气温度40分钟前的数值为24.6，空气湿度40分钟前的数值为80.69，土壤温度20分钟前的数值为24.14，空气温度20分钟前的数值为24.6，空气湿度20分钟前的数值为81.0，土壤温度当前的数值为24.09',\n",
       " '土壤温度120分钟前的数值为24.44，空气温度120分钟前的数值为25.1，空气湿度120分钟前的数值为79.3，土壤温度100分钟前的数值为24.39，空气温度100分钟前的数值为25.0，空气湿度100分钟前的数值为80.3，土壤温度80分钟前的数值为24.29，空气温度80分钟前的数值为24.8，空气湿度80分钟前的数值为80.1，土壤温度60分钟前的数值为24.19，空气温度60分钟前的数值为24.6，空气湿度60分钟前的数值为80.69，土壤温度40分钟前的数值为24.14，空气温度40分钟前的数值为24.6，空气湿度40分钟前的数值为81.0，土壤温度20分钟前的数值为24.09，空气温度20分钟前的数值为24.6，空气湿度20分钟前的数值为81.19，土壤温度当前的数值为23.99',\n",
       " '土壤温度120分钟前的数值为24.39，空气温度120分钟前的数值为25.0，空气湿度120分钟前的数值为80.3，土壤温度100分钟前的数值为24.29，空气温度100分钟前的数值为24.8，空气湿度100分钟前的数值为80.1，土壤温度80分钟前的数值为24.19，空气温度80分钟前的数值为24.6，空气湿度80分钟前的数值为80.69，土壤温度60分钟前的数值为24.14，空气温度60分钟前的数值为24.6，空气湿度60分钟前的数值为81.0，土壤温度40分钟前的数值为24.09，空气温度40分钟前的数值为24.6，空气湿度40分钟前的数值为81.19，土壤温度20分钟前的数值为23.99，空气温度20分钟前的数值为24.6，空气湿度20分钟前的数值为81.4，土壤温度当前的数值为23.94',\n",
       " '土壤温度120分钟前的数值为24.29，空气温度120分钟前的数值为24.8，空气湿度120分钟前的数值为80.1，土壤温度100分钟前的数值为24.19，空气温度100分钟前的数值为24.6，空气湿度100分钟前的数值为80.69，土壤温度80分钟前的数值为24.14，空气温度80分钟前的数值为24.6，空气湿度80分钟前的数值为81.0，土壤温度60分钟前的数值为24.09，空气温度60分钟前的数值为24.6，空气湿度60分钟前的数值为81.19，土壤温度40分钟前的数值为23.99，空气温度40分钟前的数值为24.6，空气湿度40分钟前的数值为81.4，土壤温度20分钟前的数值为23.94，空气温度20分钟前的数值为24.7，空气湿度20分钟前的数值为81.0，土壤温度当前的数值为23.89',\n",
       " '土壤温度120分钟前的数值为24.19，空气温度120分钟前的数值为24.6，空气湿度120分钟前的数值为80.69，土壤温度100分钟前的数值为24.14，空气温度100分钟前的数值为24.6，空气湿度100分钟前的数值为81.0，土壤温度80分钟前的数值为24.09，空气温度80分钟前的数值为24.6，空气湿度80分钟前的数值为81.19，土壤温度60分钟前的数值为23.99，空气温度60分钟前的数值为24.6，空气湿度60分钟前的数值为81.4，土壤温度40分钟前的数值为23.94，空气温度40分钟前的数值为24.7，空气湿度40分钟前的数值为81.0，土壤温度20分钟前的数值为23.89，空气温度20分钟前的数值为24.7，空气湿度20分钟前的数值为81.3，土壤温度当前的数值为23.84',\n",
       " '土壤温度120分钟前的数值为24.14，空气温度120分钟前的数值为24.6，空气湿度120分钟前的数值为81.0，土壤温度100分钟前的数值为24.09，空气温度100分钟前的数值为24.6，空气湿度100分钟前的数值为81.19，土壤温度80分钟前的数值为23.99，空气温度80分钟前的数值为24.6，空气湿度80分钟前的数值为81.4，土壤温度60分钟前的数值为23.94，空气温度60分钟前的数值为24.7，空气湿度60分钟前的数值为81.0，土壤温度40分钟前的数值为23.89，空气温度40分钟前的数值为24.7，空气湿度40分钟前的数值为81.3，土壤温度20分钟前的数值为23.84，空气温度20分钟前的数值为24.6，空气湿度20分钟前的数值为82.0，土壤温度当前的数值为23.79',\n",
       " '土壤温度120分钟前的数值为24.09，空气温度120分钟前的数值为24.6，空气湿度120分钟前的数值为81.19，土壤温度100分钟前的数值为23.99，空气温度100分钟前的数值为24.6，空气湿度100分钟前的数值为81.4，土壤温度80分钟前的数值为23.94，空气温度80分钟前的数值为24.7，空气湿度80分钟前的数值为81.0，土壤温度60分钟前的数值为23.89，空气温度60分钟前的数值为24.7，空气湿度60分钟前的数值为81.3，土壤温度40分钟前的数值为23.84，空气温度40分钟前的数值为24.6，空气湿度40分钟前的数值为82.0，土壤温度20分钟前的数值为23.79，空气温度20分钟前的数值为24.5，空气湿度20分钟前的数值为81.5，土壤温度当前的数值为23.79',\n",
       " '土壤温度120分钟前的数值为23.99，空气温度120分钟前的数值为24.6，空气湿度120分钟前的数值为81.4，土壤温度100分钟前的数值为23.94，空气温度100分钟前的数值为24.7，空气湿度100分钟前的数值为81.0，土壤温度80分钟前的数值为23.89，空气温度80分钟前的数值为24.7，空气湿度80分钟前的数值为81.3，土壤温度60分钟前的数值为23.84，空气温度60分钟前的数值为24.6，空气湿度60分钟前的数值为82.0，土壤温度40分钟前的数值为23.79，空气温度40分钟前的数值为24.5，空气湿度40分钟前的数值为81.5，土壤温度20分钟前的数值为23.79，空气温度20分钟前的数值为24.4，空气湿度20分钟前的数值为81.9，土壤温度当前的数值为23.68',\n",
       " '土壤温度120分钟前的数值为23.94，空气温度120分钟前的数值为24.7，空气湿度120分钟前的数值为81.0，土壤温度100分钟前的数值为23.89，空气温度100分钟前的数值为24.7，空气湿度100分钟前的数值为81.3，土壤温度80分钟前的数值为23.84，空气温度80分钟前的数值为24.6，空气湿度80分钟前的数值为82.0，土壤温度60分钟前的数值为23.79，空气温度60分钟前的数值为24.5，空气湿度60分钟前的数值为81.5，土壤温度40分钟前的数值为23.79，空气温度40分钟前的数值为24.4，空气湿度40分钟前的数值为81.9，土壤温度20分钟前的数值为23.68，空气温度20分钟前的数值为24.3，空气湿度20分钟前的数值为83.2，土壤温度当前的数值为23.66',\n",
       " '土壤温度120分钟前的数值为23.89，空气温度120分钟前的数值为24.7，空气湿度120分钟前的数值为81.3，土壤温度100分钟前的数值为23.84，空气温度100分钟前的数值为24.6，空气湿度100分钟前的数值为82.0，土壤温度80分钟前的数值为23.79，空气温度80分钟前的数值为24.5，空气湿度80分钟前的数值为81.5，土壤温度60分钟前的数值为23.79，空气温度60分钟前的数值为24.4，空气湿度60分钟前的数值为81.9，土壤温度40分钟前的数值为23.68，空气温度40分钟前的数值为24.3，空气湿度40分钟前的数值为83.2，土壤温度20分钟前的数值为23.66，空气温度20分钟前的数值为24.2，空气湿度20分钟前的数值为83.2，土壤温度当前的数值为23.58',\n",
       " '土壤温度120分钟前的数值为23.84，空气温度120分钟前的数值为24.6，空气湿度120分钟前的数值为82.0，土壤温度100分钟前的数值为23.79，空气温度100分钟前的数值为24.5，空气湿度100分钟前的数值为81.5，土壤温度80分钟前的数值为23.79，空气温度80分钟前的数值为24.4，空气湿度80分钟前的数值为81.9，土壤温度60分钟前的数值为23.68，空气温度60分钟前的数值为24.3，空气湿度60分钟前的数值为83.2，土壤温度40分钟前的数值为23.66，空气温度40分钟前的数值为24.2，空气湿度40分钟前的数值为83.2，土壤温度20分钟前的数值为23.58，空气温度20分钟前的数值为24.2，空气湿度20分钟前的数值为83.6，土壤温度当前的数值为23.58',\n",
       " '土壤温度120分钟前的数值为23.79，空气温度120分钟前的数值为24.5，空气湿度120分钟前的数值为81.5，土壤温度100分钟前的数值为23.79，空气温度100分钟前的数值为24.4，空气湿度100分钟前的数值为81.9，土壤温度80分钟前的数值为23.68，空气温度80分钟前的数值为24.3，空气湿度80分钟前的数值为83.2，土壤温度60分钟前的数值为23.66，空气温度60分钟前的数值为24.2，空气湿度60分钟前的数值为83.2，土壤温度40分钟前的数值为23.58，空气温度40分钟前的数值为24.2，空气湿度40分钟前的数值为83.6，土壤温度20分钟前的数值为23.58，空气温度20分钟前的数值为24.2，空气湿度20分钟前的数值为83.9，土壤温度当前的数值为23.51',\n",
       " '土壤温度120分钟前的数值为23.79，空气温度120分钟前的数值为24.4，空气湿度120分钟前的数值为81.9，土壤温度100分钟前的数值为23.68，空气温度100分钟前的数值为24.3，空气湿度100分钟前的数值为83.2，土壤温度80分钟前的数值为23.66，空气温度80分钟前的数值为24.2，空气湿度80分钟前的数值为83.2，土壤温度60分钟前的数值为23.58，空气温度60分钟前的数值为24.2，空气湿度60分钟前的数值为83.6，土壤温度40分钟前的数值为23.58，空气温度40分钟前的数值为24.2，空气湿度40分钟前的数值为83.9，土壤温度20分钟前的数值为23.51，空气温度20分钟前的数值为24.4，空气湿度20分钟前的数值为83.2，土壤温度当前的数值为23.48',\n",
       " '土壤温度120分钟前的数值为23.68，空气温度120分钟前的数值为24.3，空气湿度120分钟前的数值为83.2，土壤温度100分钟前的数值为23.66，空气温度100分钟前的数值为24.2，空气湿度100分钟前的数值为83.2，土壤温度80分钟前的数值为23.58，空气温度80分钟前的数值为24.2，空气湿度80分钟前的数值为83.6，土壤温度60分钟前的数值为23.58，空气温度60分钟前的数值为24.2，空气湿度60分钟前的数值为83.9，土壤温度40分钟前的数值为23.51，空气温度40分钟前的数值为24.4，空气湿度40分钟前的数值为83.2，土壤温度20分钟前的数值为23.48，空气温度20分钟前的数值为24.2，空气湿度20分钟前的数值为83.8，土壤温度当前的数值为23.48',\n",
       " '土壤温度120分钟前的数值为23.66，空气温度120分钟前的数值为24.2，空气湿度120分钟前的数值为83.2，土壤温度100分钟前的数值为23.58，空气温度100分钟前的数值为24.2，空气湿度100分钟前的数值为83.6，土壤温度80分钟前的数值为23.58，空气温度80分钟前的数值为24.2，空气湿度80分钟前的数值为83.9，土壤温度60分钟前的数值为23.51，空气温度60分钟前的数值为24.4，空气湿度60分钟前的数值为83.2，土壤温度40分钟前的数值为23.48，空气温度40分钟前的数值为24.2，空气湿度40分钟前的数值为83.8，土壤温度20分钟前的数值为23.48，空气温度20分钟前的数值为24.2，空气湿度20分钟前的数值为84.9，土壤温度当前的数值为23.48',\n",
       " '土壤温度120分钟前的数值为23.58，空气温度120分钟前的数值为24.2，空气湿度120分钟前的数值为83.6，土壤温度100分钟前的数值为23.58，空气温度100分钟前的数值为24.2，空气湿度100分钟前的数值为83.9，土壤温度80分钟前的数值为23.51，空气温度80分钟前的数值为24.4，空气湿度80分钟前的数值为83.2，土壤温度60分钟前的数值为23.48，空气温度60分钟前的数值为24.2，空气湿度60分钟前的数值为83.8，土壤温度40分钟前的数值为23.48，空气温度40分钟前的数值为24.2，空气湿度40分钟前的数值为84.9，土壤温度20分钟前的数值为23.48，空气温度20分钟前的数值为24.2，空气湿度20分钟前的数值为84.3，土壤温度当前的数值为23.48',\n",
       " '土壤温度120分钟前的数值为23.58，空气温度120分钟前的数值为24.2，空气湿度120分钟前的数值为83.9，土壤温度100分钟前的数值为23.51，空气温度100分钟前的数值为24.4，空气湿度100分钟前的数值为83.2，土壤温度80分钟前的数值为23.48，空气温度80分钟前的数值为24.2，空气湿度80分钟前的数值为83.8，土壤温度60分钟前的数值为23.48，空气温度60分钟前的数值为24.2，空气湿度60分钟前的数值为84.9，土壤温度40分钟前的数值为23.48，空气温度40分钟前的数值为24.2，空气湿度40分钟前的数值为84.3，土壤温度20分钟前的数值为23.48，空气温度20分钟前的数值为24.2，空气湿度20分钟前的数值为84.3，土壤温度当前的数值为23.48',\n",
       " '土壤温度120分钟前的数值为23.51，空气温度120分钟前的数值为24.4，空气湿度120分钟前的数值为83.2，土壤温度100分钟前的数值为23.48，空气温度100分钟前的数值为24.2，空气湿度100分钟前的数值为83.8，土壤温度80分钟前的数值为23.48，空气温度80分钟前的数值为24.2，空气湿度80分钟前的数值为84.9，土壤温度60分钟前的数值为23.48，空气温度60分钟前的数值为24.2，空气湿度60分钟前的数值为84.3，土壤温度40分钟前的数值为23.48，空气温度40分钟前的数值为24.2，空气湿度40分钟前的数值为84.3，土壤温度20分钟前的数值为23.48，空气温度20分钟前的数值为24.5，空气湿度20分钟前的数值为83.5，土壤温度当前的数值为23.48',\n",
       " '土壤温度120分钟前的数值为23.48，空气温度120分钟前的数值为24.2，空气湿度120分钟前的数值为83.8，土壤温度100分钟前的数值为23.48，空气温度100分钟前的数值为24.2，空气湿度100分钟前的数值为84.9，土壤温度80分钟前的数值为23.48，空气温度80分钟前的数值为24.2，空气湿度80分钟前的数值为84.3，土壤温度60分钟前的数值为23.48，空气温度60分钟前的数值为24.2，空气湿度60分钟前的数值为84.3，土壤温度40分钟前的数值为23.48，空气温度40分钟前的数值为24.5，空气湿度40分钟前的数值为83.5，土壤温度20分钟前的数值为23.48，空气温度20分钟前的数值为24.6，空气湿度20分钟前的数值为82.9，土壤温度当前的数值为23.51',\n",
       " '土壤温度120分钟前的数值为23.48，空气温度120分钟前的数值为24.2，空气湿度120分钟前的数值为84.9，土壤温度100分钟前的数值为23.48，空气温度100分钟前的数值为24.2，空气湿度100分钟前的数值为84.3，土壤温度80分钟前的数值为23.48，空气温度80分钟前的数值为24.2，空气湿度80分钟前的数值为84.3，土壤温度60分钟前的数值为23.48，空气温度60分钟前的数值为24.5，空气湿度60分钟前的数值为83.5，土壤温度40分钟前的数值为23.48，空气温度40分钟前的数值为24.6，空气湿度40分钟前的数值为82.9，土壤温度20分钟前的数值为23.51，空气温度20分钟前的数值为24.6，空气湿度20分钟前的数值为82.6，土壤温度当前的数值为23.53',\n",
       " '土壤温度120分钟前的数值为23.48，空气温度120分钟前的数值为24.2，空气湿度120分钟前的数值为84.3，土壤温度100分钟前的数值为23.48，空气温度100分钟前的数值为24.2，空气湿度100分钟前的数值为84.3，土壤温度80分钟前的数值为23.48，空气温度80分钟前的数值为24.5，空气湿度80分钟前的数值为83.5，土壤温度60分钟前的数值为23.48，空气温度60分钟前的数值为24.6，空气湿度60分钟前的数值为82.9，土壤温度40分钟前的数值为23.51，空气温度40分钟前的数值为24.6，空气湿度40分钟前的数值为82.6，土壤温度20分钟前的数值为23.53，空气温度20分钟前的数值为24.8，空气湿度20分钟前的数值为81.69，土壤温度当前的数值为23.58',\n",
       " '土壤温度120分钟前的数值为23.48，空气温度120分钟前的数值为24.2，空气湿度120分钟前的数值为84.3，土壤温度100分钟前的数值为23.48，空气温度100分钟前的数值为24.5，空气湿度100分钟前的数值为83.5，土壤温度80分钟前的数值为23.48，空气温度80分钟前的数值为24.6，空气湿度80分钟前的数值为82.9，土壤温度60分钟前的数值为23.51，空气温度60分钟前的数值为24.6，空气湿度60分钟前的数值为82.6，土壤温度40分钟前的数值为23.53，空气温度40分钟前的数值为24.8，空气湿度40分钟前的数值为81.69，土壤温度20分钟前的数值为23.58，空气温度20分钟前的数值为24.7，空气湿度20分钟前的数值为82.3，土壤温度当前的数值为23.58',\n",
       " '土壤温度120分钟前的数值为23.48，空气温度120分钟前的数值为24.5，空气湿度120分钟前的数值为83.5，土壤温度100分钟前的数值为23.48，空气温度100分钟前的数值为24.6，空气湿度100分钟前的数值为82.9，土壤温度80分钟前的数值为23.51，空气温度80分钟前的数值为24.6，空气湿度80分钟前的数值为82.6，土壤温度60分钟前的数值为23.53，空气温度60分钟前的数值为24.8，空气湿度60分钟前的数值为81.69，土壤温度40分钟前的数值为23.58，空气温度40分钟前的数值为24.7，空气湿度40分钟前的数值为82.3，土壤温度20分钟前的数值为23.58，空气温度20分钟前的数值为24.7，空气湿度20分钟前的数值为82.3，土壤温度当前的数值为23.58',\n",
       " '土壤温度120分钟前的数值为23.48，空气温度120分钟前的数值为24.6，空气湿度120分钟前的数值为82.9，土壤温度100分钟前的数值为23.51，空气温度100分钟前的数值为24.6，空气湿度100分钟前的数值为82.6，土壤温度80分钟前的数值为23.53，空气温度80分钟前的数值为24.8，空气湿度80分钟前的数值为81.69，土壤温度60分钟前的数值为23.58，空气温度60分钟前的数值为24.7，空气湿度60分钟前的数值为82.3，土壤温度40分钟前的数值为23.58，空气温度40分钟前的数值为24.7，空气湿度40分钟前的数值为82.3，土壤温度20分钟前的数值为23.58，空气温度20分钟前的数值为24.7，空气湿度20分钟前的数值为82.7，土壤温度当前的数值为23.58',\n",
       " '土壤温度120分钟前的数值为23.51，空气温度120分钟前的数值为24.6，空气湿度120分钟前的数值为82.6，土壤温度100分钟前的数值为23.53，空气温度100分钟前的数值为24.8，空气湿度100分钟前的数值为81.69，土壤温度80分钟前的数值为23.58，空气温度80分钟前的数值为24.7，空气湿度80分钟前的数值为82.3，土壤温度60分钟前的数值为23.58，空气温度60分钟前的数值为24.7，空气湿度60分钟前的数值为82.3，土壤温度40分钟前的数值为23.58，空气温度40分钟前的数值为24.7，空气湿度40分钟前的数值为82.7，土壤温度20分钟前的数值为23.58，空气温度20分钟前的数值为24.8，空气湿度20分钟前的数值为82.4，土壤温度当前的数值为23.63',\n",
       " '土壤温度120分钟前的数值为23.53，空气温度120分钟前的数值为24.8，空气湿度120分钟前的数值为81.69，土壤温度100分钟前的数值为23.58，空气温度100分钟前的数值为24.7，空气湿度100分钟前的数值为82.3，土壤温度80分钟前的数值为23.58，空气温度80分钟前的数值为24.7，空气湿度80分钟前的数值为82.3，土壤温度60分钟前的数值为23.58，空气温度60分钟前的数值为24.7，空气湿度60分钟前的数值为82.7，土壤温度40分钟前的数值为23.58，空气温度40分钟前的数值为24.8，空气湿度40分钟前的数值为82.4，土壤温度20分钟前的数值为23.63，空气温度20分钟前的数值为24.8，空气湿度20分钟前的数值为82.0，土壤温度当前的数值为23.68',\n",
       " '土壤温度120分钟前的数值为23.58，空气温度120分钟前的数值为24.7，空气湿度120分钟前的数值为82.3，土壤温度100分钟前的数值为23.58，空气温度100分钟前的数值为24.7，空气湿度100分钟前的数值为82.3，土壤温度80分钟前的数值为23.58，空气温度80分钟前的数值为24.7，空气湿度80分钟前的数值为82.7，土壤温度60分钟前的数值为23.58，空气温度60分钟前的数值为24.8，空气湿度60分钟前的数值为82.4，土壤温度40分钟前的数值为23.63，空气温度40分钟前的数值为24.8，空气湿度40分钟前的数值为82.0，土壤温度20分钟前的数值为23.68，空气温度20分钟前的数值为24.8，空气湿度20分钟前的数值为81.69，土壤温度当前的数值为23.68',\n",
       " '土壤温度120分钟前的数值为23.58，空气温度120分钟前的数值为24.7，空气湿度120分钟前的数值为82.3，土壤温度100分钟前的数值为23.58，空气温度100分钟前的数值为24.7，空气湿度100分钟前的数值为82.7，土壤温度80分钟前的数值为23.58，空气温度80分钟前的数值为24.8，空气湿度80分钟前的数值为82.4，土壤温度60分钟前的数值为23.63，空气温度60分钟前的数值为24.8，空气湿度60分钟前的数值为82.0，土壤温度40分钟前的数值为23.68，空气温度40分钟前的数值为24.8，空气湿度40分钟前的数值为81.69，土壤温度20分钟前的数值为23.68，空气温度20分钟前的数值为24.8，空气湿度20分钟前的数值为81.8，土壤温度当前的数值为23.68',\n",
       " '土壤温度120分钟前的数值为23.58，空气温度120分钟前的数值为24.7，空气湿度120分钟前的数值为82.7，土壤温度100分钟前的数值为23.58，空气温度100分钟前的数值为24.8，空气湿度100分钟前的数值为82.4，土壤温度80分钟前的数值为23.63，空气温度80分钟前的数值为24.8，空气湿度80分钟前的数值为82.0，土壤温度60分钟前的数值为23.68，空气温度60分钟前的数值为24.8，空气湿度60分钟前的数值为81.69，土壤温度40分钟前的数值为23.68，空气温度40分钟前的数值为24.8，空气湿度40分钟前的数值为81.8，土壤温度20分钟前的数值为23.68，空气温度20分钟前的数值为24.7，空气湿度20分钟前的数值为82.5，土壤温度当前的数值为23.68']"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[1030:1060]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'土壤温度120分钟前的数值为23.58，空气温度120分钟前的数值为24.8，空气湿度120分钟前的数值为82.4，土壤温度100分钟前的数值为23.63，空气温度100分钟前的数值为24.8，空气湿度100分钟前的数值为82.0，土壤温度80分钟前的数值为23.68，空气温度80分钟前的数值为24.8，空气湿度80分钟前的数值为81.69，土壤温度60分钟前的数值为23.68，空气温度60分钟前的数值为24.8，空气湿度60分钟前的数值为81.8，土壤温度40分钟前的数值为23.68，空气温度40分钟前的数值为24.7，空气湿度40分钟前的数值为82.5，土壤温度20分钟前的数值为23.68，空气温度20分钟前的数值为24.7，空气湿度20分钟前的数值为82.3，土壤温度当前的数值为23.68'"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[1060]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'土壤温度120分钟前的数值为23.58，空气温度120分钟前的数值为24.8，空气湿度120分钟前的数值为82.4，土壤温度100分钟前的数值为23.63，空气温度100分钟前的数值为24.8，空气湿度100分钟前的数值为82.0，土壤温度80分钟前的数值为23.68，空气温度80分钟前的数值为24.8，空气湿度80分钟前的数值为81.69，土壤温度60分钟前的数值为23.68，空气温度60分钟前的数值为24.8，空气湿度60分钟前的数值为81.8，土壤温度40分钟前的数值为23.68，空气温度40分钟前的数值为24.7，空气湿度40分钟前的数值为82.5，土壤温度20分钟前的数值为23.68，空气温度20分钟前的数值为24.7，空气湿度20分钟前的数值为82.3'"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[1060].rsplit(\"，\", 1)[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\n\\n根据历史数据的趋势分析，当前土壤温度预测值为 **23.68°C**。\\n\\n### 分析过程：\\n1. **历史趋势观察**：  \\n   - 在最近的历史数据中，当土壤温度在连续多个时间点（如20分钟、40分钟等）保持稳定时（如23.68），当前温度通常维持不变。\\n   - 例如，最后几条历史数据显示土壤温度稳定在23.68，即使空气温度有轻微波动（24.7~24.8°C），土壤温度仍未变化。\\n\\n2. **输入数据的特征**：  \\n   - 预测数据中，土壤温度从 **120分钟前的23.58** 逐渐上升至 **80分钟前的23.68**，随后保持稳定至 **20分钟前的23.68**。  \\n   - 空气温度从24.8°C小幅降至24.7°C，湿度稳定在82%左右，变化幅度不足以显著影响土壤温度。\\n\\n3. **结论**：  \\n   基于历史稳定状态及输入数据的连续性，当前土壤温度预计与最近时间点（20分钟前）的数值一致，即 **23.68°C**。'"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain.invoke({'history': text[1030:1070],'today': text[1060].rsplit(\"，\", 1)[0]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "prompt_1 = ChatPromptTemplate.from_template(\"\"\"\n",
    "根据文本{text}，直接输出预测土壤温度的预测结果。\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\n\\n**预测结果**：土壤温度为 **23.68°C**。'"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "llm_1 = ChatOpenAI(model=\"SparkDesk-v1.1\", temperature=0,api_key='sk-zk296e1a1b3cdb88c1be349e0da6283e0036757dc77b0f0d',base_url='https://api.zhizengzeng.com/v1')\n",
    "chain_1 = prompt_1 | llm | parser\n",
    "chain_1.invoke({'text':'\\n\\n根据历史数据的趋势分析，当前土壤温度预测值为 **23.68°C**。\\n\\n### 分析过程：\\n1. **历史趋势观察**：  \\n   - 在最近的历史数据中，当土壤温度在连续多个时间点（如20分钟、40分钟等）保持稳定时（如23.68），当前温度通常维持不变。\\n   - 例如，最后几条历史数据显示土壤温度稳定在23.68，即使空气温度有轻微波动（24.7~24.8°C），土壤温度仍未变化。\\n\\n2. **输入数据的特征**：  \\n   - 预测数据中，土壤温度从 **120分钟前的23.58** 逐渐上升至 **80分钟前的23.68**，随后保持稳定至 **20分钟前的23.68**。  \\n   - 空气温度从24.8°C小幅降至24.7°C，湿度稳定在82%左右，变化幅度不足以显著影响土壤温度。\\n\\n3. **结论**：  \\n   基于历史稳定状态及输入数据的连续性，当前土壤温度预计与最近时间点（20分钟前）的数值一致，即 **23.68°C**。'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "'''\n",
    "1. 可以尝试喂更少的更多的数据，看能不能有更好的效果，目前测试是30条\n",
    "2. 改进prompt模板，例如换数据展示的模板？可以给更多详细的角色定位，或者给予任务提示，比如诱导它每次都分析数学公式进行拟合？都可以，可以多尝试多种prompt\n",
    "3. 可以尝试进行多步多变量预测，测试一下性能。pipline自己写，提高代码水平\n",
    "4. 或许相关的数据预处理，比如去噪声，或者特征筛选，也能提高一些预测效果？后续或者也可以尝试区间预测，让它输出预测区间\n",
    "5. 查阅相关的llm时序相关论文，或许可以提取一些灵感？最终要prompt模板的设定，以及如何给好的例子\n",
    "'''"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
